/** create by liuhua at 2017年5月26日 上午11:09:40 **/
package com.star.truffle.core.security.dto;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.security.core.authority.SimpleGrantedAuthority;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class StarUserInfoTemp {
  
  private String password;
  private String username;
  private List<Authority> authorities;
  private boolean accountNonExpired;
  private boolean accountNonLocked;
  private boolean credentialsNonExpired;
  private boolean enabled;

  private Long userId;

  private List<String> roles;

  private String userType;
  
  private String typeName;

  private List<UserInfo> userInfos;

  private String token;

  private long loginTime;

  private List<Map<String, Object>> navMenus;

  private List<Map<String, Object>> menu;
  
  public StarUserInfo getUserInfo() {
    List<SimpleGrantedAuthority> authorities = new ArrayList<>();
    if(null != this.authorities && ! this.authorities.isEmpty()) {
      authorities = this.authorities.stream().map(auth -> new SimpleGrantedAuthority(auth.getAuthority())).collect(Collectors.toList());
    }
    return new StarUserInfo("123aa", username, authorities, accountNonExpired, accountNonLocked, credentialsNonExpired, enabled, userId, roles, userType, typeName, userInfos, token, loginTime, navMenus, menu);
  }
  
  @Data
  public static class Authority {
    private String authority;
  }
}
